<%@ page language="java" import="java.util.*,entity.*,dao.*,dao.impl.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<% 
TopicDao topicDao = new TopicDaoImpl();
ReplyDao replyDao = new ReplyDaoImpl();
UserDao userDao = new UserDaoImpl();
BoardDao boardDao = new BoardDaoImpl();
int boardId = Integer.parseInt(request.getParameter("boardId"));
int topicId = Integer.parseInt(request.getParameter("topicId"));
int p = Integer.parseInt(request.getParameter("page"));
Board board = boardDao.findBoard(boardId);
Topic topic = topicDao.findTopic(topicId);
User topicUser = userDao.findUser(topic.getUid());
List listReply = replyDao.findListReply(p, topicId);

int prep = p;
int nextp = p;
if(listReply.size()==10){
	nextp = p+1;
}
if(p>1){
	prep = p-1;
}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#apDiv1 {
	position: absolute;
	left: 1px;
	top: 1px;
	width: 800px;
	height: 50px;
	z-index: 1;
	text-align: center;
	font-weight: bold;
	font-size: 36px;
	color: #F00;
}
#apDiv2 {
	position: absolute;
	left: 1px;
	top: 51px;
	width: 800px;
	height: 25px;
	z-index: 2;
	font-size: 12px;
	background-color: #e0f0f9;
	color: #004c7d;
}
#apDiv3 {
	position: absolute;
	left: 1px;
	top: 76px;
	width: 800px;
	height: 50px;
	z-index: 3;
	color: #000;
	text-align: center;
}
#apDiv3 table tr td {
	font-size: 12px;
	color: #004c7d;
	text-align: left;
}

#apDiv4 {
	position: absolute;
	left: 1px;
	top: 146px;
	width: 800px;
	height: 800px;
	z-index: 3;
	color: #000;
	text-align: center;
}

</style>
</head>

<body>
<div id="apDiv1">校园BBS系统</div>
<div id="apDiv2">您尚未 <a href="login.jsp">登录</a>  | <a href="reg.jsp">注册</a></div>
<div id="apDiv3">
<form id="form1" name="form1" method="post" action="">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="31" colspan="2">&gt;&gt;<a href="index.jsp">论坛首页</a>&gt;&gt;
      <a href="list.jsp?page=1&boardId=<%=boardId %>"><%=board.getBoardName() %></a></td>
      <td width="6%">&nbsp;</td>
      <td width="6%">&nbsp;</td>
      <td width="7%">&nbsp;</td> 
    </tr>
    <tr>
      <td width="14%" height="19">
        <a href="reply.jsp?topicId=<%=topicId %>&boardId=<%=boardId %>">回复帖子</a>
      </td>
      <td width="67%">
        <a href="post.jsp?boardId=<%=boardId %>">发布话题</a>
      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td height="61">
	  </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>
</div>
<div id="apDiv4">
  <form id="form2" name="form2" method="post" action="">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <!-- 主题标题 -->
      <tr>
        <td width="14%">本页主题：<%=topic.getTitle() %></td>
        <td width="86%">&nbsp;</td>
      </tr>
      <!-- 主题 -->
      <%
      if(p==1){
       %>
      <tr>
        <td><b><%=topicUser.getUName() %></b></td>
        <td><img src = "image/head/<%=topicUser.getHead() %>"/></td>
      </tr>
      <tr>
        <td><h4 align="left"><%=topic.getTitle() %></h4></td>
        <td><%=topic.getContent() %></td>
      </tr>
      <tr>
        <td>发表：[<%=topic.getPublishTime() %>]</td>
        <td>最后修改：[<%=topic.getModifyTime() %>]</td>
      </tr>
      <!-- 回复 -->
      <%
      }
      for(int i = 0; i < listReply.size(); i++){
      	Reply reply = (Reply)listReply.get(i);
      	User replyUser = (User)userDao.findUser(reply.getUid());
       %>
      <tr>
        <td><b><%=replyUser.getUName() %></b></td>
        <td><img src = "image/head/<%=replyUser.getHead() %>"/></td>
      </tr>
      <tr>
        <td><h4 align="left"><%=reply.getTitle() %></h4></td>
        <td><%=reply.getContent() %></td>
      </tr>
      <tr>
        <td>发表：[<%=reply.getPublishTime() %>]</td>
        <td>最后修改：[<%=reply.getModifyTime() %>]</td>
      </tr>
		<%
		}
		 %>
      <tr>
        <td><a href="detail.jsp?page=<%=prep %>&boardId=<%=boardId %>&topicId=<%=topicId %>">上一页</a></td>
        <td><a href="detail.jsp?page=<%=nextp %>&boardId=<%=boardId %>&topicId=<%=topicId %>">下一页</a></td>
      </tr>
    </table>
  </form>
</div>
</body>
</html>

